var barcode = require('./barcode');
var qrcode = require('./qrcode');
var wxqrcode = require('./weapp.qrcode.2d.esm');

function barc(ctx, conf) {
  const dpr = wx.getWindowInfo().pixelRatio
  const screenWidth = wx.getWindowInfo().screenWidth * dpr;
  // const screenHeight = wx.getWindowInfo().screenHeight * dpr;
  // console.log(screenWidth,screenHeight,dpr);
  conf.width = Math.floor((conf.width / 750 * screenWidth) / dpr);
  conf.height = Math.floor((conf.height / 750 * screenWidth) / dpr);
  barcode.code128(ctx, conf);
}

function qrc(canvas, ctx, conf) {

  const dpr = wx.getWindowInfo().pixelRatio
  const screenWidth = wx.getWindowInfo().screenWidth * dpr;
  conf.size = Math.floor((conf.size / 750 * screenWidth) / dpr);
  qrcode.api.draw(canvas, ctx, conf);
}

function wxqrcodecanvas(conf) {
  wxqrcode.drawQrcode(conf)
}
module.exports = {
  barcode: barc,
  qrcode: qrc,
  wxqrcode: wxqrcodecanvas
}